package com.alix.paymoney.presenter.impl;

import com.alix.paymoney.entity.BaseBean;
import com.alix.paymoney.http.CallManager;
import com.alix.paymoney.http.HttpManager;
import com.alix.paymoney.http.OnResponseListener;
import com.alix.paymoney.http.request.VerifyRequest;
import com.alix.paymoney.presenter.VerifyInfoPresneter;
import com.alix.paymoney.utils.Loger;
import com.alix.paymoney.view.VerifyInfoView;

import retrofit2.Call;

/**
 * Created by wushiqian on 2017/11/14.
 */

public class VerifyInfoPresenterImpl extends BasePresenterImpl<VerifyInfoView> implements VerifyInfoPresneter {
    public VerifyInfoPresenterImpl(VerifyInfoView verifyInfoView) {
        super(verifyInfoView);
    }

    @Override
    public void verifyInfo(String token, String name, String cetNumber, String educationId) {
        VerifyRequest verifyRequest = new VerifyRequest();
        verifyRequest.setToken(token);
        verifyRequest.setCertNo(cetNumber);
        verifyRequest.setRealName(name);
        verifyRequest.setEducationId(educationId);

        Call<BaseBean> baseBeanCall = HttpManager.getInstance().getApiService().verifyInfo(verifyRequest);
        CallManager.getInstance().addQueue(baseBeanCall, new OnResponseListener<BaseBean>() {
            @Override
            public void Success(BaseBean o) {
                getView().verifySuccess();
            }

            @Override
            public void onFailed(int errorCode, String errorInfo) {
                getView().vefiryError(errorCode, errorInfo);
                Loger.e("认证信息");
            }

            @Override
            public void onException(String msg) {
                getView().showTips(msg);
                Loger.e("认证信息");
            }
        });
    }
}
